/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
	"barge/app"
	"fmt"
	"github.com/rs/zerolog/log"
	"github.com/spf13/cobra"
	"github.com/spf13/viper"
)

// listCmd represents the version command
var listCmd = &cobra.Command{
	Use: "list",
	Aliases: []string{
		"ls",
	},
	Short: "展示所有配置信息",
	Long:  ``,
	Run: func(cmd *cobra.Command, args []string) {
		m, err := app.NewConfigManager(viper.GetString("configPath"))
		if err != nil {
			log.Err(err).Str("path", viper.GetString("configPath")).Send()
			return
		}
		fmt.Println()
		fmt.Println("控制规则：")
		m.ListRule()
		fmt.Println()
		fmt.Println("中转服务器：")
		m.ListCenter()
		fmt.Println()
		fmt.Println("镜像仓库：")
		m.ListRegistry()
	},
}

func init() {
	rootCmd.AddCommand(listCmd)
}
